<?php
session_start();
$user = $_SESSION['user'];
require_once "../../php/config/database.php";
require_once "../../php/user/userDb.php";
$UserDb=new UserDb();
$data=$UserDb->queryUser($user);
$group=$data[0]['class'];
$admin=$data[0]['admin'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">

    <link rel="shortcut icon" href="../ico/logo.ico" type="image/x-icon" />
    <title>协同办公</title>
    <link rel="stylesheet" href="../../static/css/bootstrap.css">
    <link rel="stylesheet" href="../../static/js/layui/css/layui.css">
    <link rel="stylesheet" href="../../static/css/font.css">
    <link rel="stylesheet" href="../../static/css/main.css">
</head>
<body>
<div id="logo"><div id="logo-img"><img src="../../static/imaegs/logo/logo2.png"></div>
<div id="logo-right">
    <h5 ><i class="layui-icon" style="font-size: 18px; color: orange">&#xe645;</i>&nbsp;最新公告：<span id="notice">暂无公告</span></h5>
</div>
</div>
<div id="tiao">
    <div id="left"><a href="index.php"><i class="layui-icon" style="font-size: 20px; color: #1E9FFF;">&#xe68e;</i>&nbsp;首页</a>
        <a href="task_list.php"> <i class="layui-icon" style="font-size: 20px; color: #1E9FFF;">&#xe6b2;</i>&nbsp;任务</a>
        <a href="file.php"><i class="layui-icon" style="font-size: 20px; color: #1E9FFF;">&#xe621;</i>&nbsp;文件管理</a>
        <a style="color: blue"><i class="layui-icon" style="font-size: 20px; color: #1E9FFF;">&#xe613;</i>&nbsp;用户管理</a></div>
    <div id="right"><a style="color:grey" href="index.php">您好！&nbsp;</a><i class="layui-icon" style="font-size: 20px; color: #1E9FFF;">&#xe66f;</i><input id="user" name="user" readonly="readonly" value="<?php echo $user ?>"><a onclick="out()">退出</a></div>
</div>

<div id="from_block">
    <input style="display: none" type="text" id="admin" value="<?php echo $admin; ?>">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>团队成员信息--<?php echo $group; ?> &nbsp;    <button style="float:right;" class="layui-btn layui-btn-primary layui-btn-sm">导出为Excel表</button></legend>
    </fieldset>
    <table class="layui-table" lay-data="{ height:500, url:'../../php/user/select_user_class.php?class=<?php echo $group ?>', page:true, id:'idTest'}" lay-filter="demo">
        <thead>
        <tr>
            <th lay-data="{field:'id', width:180, sort: true, fixed: true}">ID</th>
            <th lay-data="{field:'user', width:200}">用户名</th>
            <th lay-data="{field:'email', width:200}">邮箱</th>
            <th lay-data="{field:'tel', width:200}">电话</th>
            <th lay-data="{fixed: 'right', width:300, align:'center', toolbar: '#barDemo'}">备注</th>

        </tr>
        </thead>
    </table>
    <script id="barDemo" type="text/html">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">暂无</a>
<!--        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail" style="width: 50px"><img style="width: 100%;" src=""/></a>-->
    </script


</div>


<img id="hua1" src="../../static/imaegs/122.png">

<script src="../../static/js/jquery.min.js"></script>
<script src="../../static/js/layui/layui.all.js"></script>
<script>


    layui.use('table', function(){
        var table = layui.table;
        //监听表格复选框选择alert(count);
        table.on('checkbox(demo)', function(obj){
            console.log(obj);

        });
        //监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                layer.msg(data.user );

            } else if(obj.event === 'del'){
              $id=data.id;
                layer.confirm('真的删除行么', function(index) {
                    member_del($id);
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                $id=data.id;
                member_edit($id);
            }
        });

        var $ = layui.$, active = {
            getCheckData: function(){ //获取选中数据
                var checkStatus = table.checkStatus('idTest')
                    ,data = checkStatus.data;
                layer.alert(JSON.stringify(data));
            }
            ,getCheckLength: function(){ //获取选中数目
                var checkStatus = table.checkStatus('idTest')
                    ,data = checkStatus.data;
                layer.msg('选中了：'+ data.length + ' 个');
            }
            ,isAll: function(){ //验证是否全选
                var checkStatus = table.checkStatus('idTest');
                layer.msg(checkStatus.isAll ? '全选': '未全选')
            }
        };

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });


    if($('#user').val()===""){
        layer.msg("您还没有登陆哦！");
        window.location.href="login.html";

    }


    var admin=document.getElementById("admin").value;
    $.ajax({
        type: 'post',
        cache: false,
        url: '../../php/admin/select_notice.php',
        data: {
            "user":admin,
        },
        dataType: 'json',
        success: function (data) {
            $dat = data.data;
            $notice=$dat[0].content;
            var not=document.getElementById("notice");
            not.innerHTML=$notice;
        },
        error: function (data) {
            layer.msg("暂无公告");
        }
    });

    function out() {
        layer.confirm('真的要退出吗？', function(index) {
            window.location.href="../../php/user/clearSession.php";
        })
    }
</script>

</body>
</html>